package snowflake

import (
	"gitee.com/tiger000/taishan_web/utils/snowflake/bit53"
	"gitee.com/tiger000/taishan_web/utils/snowflake/bit64"
	"sync"
)

// 64位生成器
var instanceBit64 *bit64.Worker
var onceBit64 sync.Once
var err error

// 获取64bitID生成器单例
func GetBit64Instance() *bit64.Worker {
	onceBit64.Do(func() {
		instanceBit64 = bit64.New()
	})
	if err != nil {
		return nil
	}
	return instanceBit64
}

// 53位生成器
var instanceBit53 *bit53.Worker
var onceBit53 sync.Once

// 获取ID生成器单例
func GetJS53Instance() *bit53.Worker {
	onceBit53.Do(func() {
		instanceBit53 = bit53.New()
	})
	if err != nil {
		return nil
	}
	return instanceBit53
}
